package com.read.dubbo_client_demo;

import java.util.UUID;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.read.dubbo_client_demo.action.ClientAction;
import com.read.dubbo_server_demo.entity.User;
import com.read.dubbo_server_demo.service.UserService;


public class ClientDemo {
	public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("client.xml");
        
        ClientAction c = (ClientAction) context.getBean("clientAction");
        c.save(getuUser());
        /*DemoService demoService = (DemoService)context.getBean("demoService"); // 获取远程服务代理
        String hello = demoService.sayHello("world"); // 执行远程方法
 
        System.out.println( hello ); // 显示调用结果 
        
        UserService userService = (UserService)context.getBean("userService");
        User user = new User();
        user.setId(UUID.randomUUID().toString());
        user.setName("read-ke");
        user.setAge(22);
        user.setSex(1);
        userService.save(user);*/
        /*User user = userService.get("1");
        System.out.println(user);*/
        
   }
	public static User getuUser(){
		User user = new User();
        user.setId(UUID.randomUUID().toString());
        user.setName("read-ke");
        user.setAge(22);
        user.setSex(1);
        return user;
	}
 
}
